package com.ttsx.core.common.enums;

import lombok.Getter;

import java.util.stream.Stream;

/**
 * @author wb
 * @since 2025-03-04
 */

@Getter
public enum OrderStatusEnum {

    UNKNOWN(-1, "未知"),
    UNPAID(0, "待付款"),
    UNSHIPPED(1, "待发货"),
    SHIPPED(2, "已发货"),
    COMPLETED(3, "已完成"),
    CANCELED(4, "已取消"),
    REFUNDED(5, "已关闭");


    private final Integer code;
    private final String desc;


    OrderStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }


    public static String getDesc(Integer code){
        return Stream.of(OrderStatusEnum.values())
                .filter(orderStatusEnum -> orderStatusEnum.getCode().equals(code))
                .findAny()
                .orElse(UNKNOWN)
                .getDesc();
    }

}
